package com.film.rowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.film.domain.Film;
import com.film.domain.FilmOffice;
import com.film.domain.FilmShowings;

public class ShowingsRowMapper implements RowMapper<FilmShowings>{

	@Override
	public FilmShowings mapRow(ResultSet res, int i) throws SQLException {
		FilmShowings filmShowings = new FilmShowings();
		filmShowings.setShowingsId(res.getInt("showings_id"));
		
		Film film = new Film();
		film.setFilmId(res.getInt("film_id"));
		film.setFilmName(res.getString("film_name"));
		film.setFilmForeignName(res.getString("film_foreignName"));
		film.setFilmPlace(res.getString("film_place"));
		film.setFilmTime(res.getString("film_time"));
		film.setFilmShowTime(res.getString("film_showTime"));
		film.setFilmImg(res.getString("film_img"));
		film.setIsDelete(res.getInt("is_delete"));
		film.setBoxoffice(res.getFloat("boxoffice"));
		film.setExpect(res.getInt("expect"));
		film.setFilmIunguage(res.getString("film_lunguage"));
		film.setFilmIntroduce(res.getString("film_introduce"));
		filmShowings.setFilm(film);
		
		filmShowings.setShowingsDay(res.getString("showings_day"));
		filmShowings.setShowingsStartTime(res.getString("showings_starttime"));
		filmShowings.setShowingsEndTime(res.getString("showings_endtime"));
		
		FilmOffice filmOffice = new FilmOffice();
		filmOffice.setOffId(res.getInt("off_id"));
		filmOffice.setOffName(res.getString("off_name"));
		filmShowings.setFilmOffice(filmOffice);
		
		filmShowings.setShowingsPrice(res.getDouble("showings_price"));
		filmShowings.setShowingsCreateTime(res.getString("showings_createTime"));
		filmShowings.setShowingsUpdateTime(res.getString("showings_updateTime"));
		filmShowings.setIsDelete(res.getInt("is_delete"));
		return filmShowings;
	}

}
